package com.demo.consumer.controller.apm;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RedisController {

    //需要加上redis序列化的操作，装配更改过的的RedisTemplate bean
    @Autowired
    private RedisTemplate redisTemplate;

    private static final Logger log = LoggerFactory.getLogger(ApmDeomController.class);

    @RequestMapping(value = "/redistest")
    public  Boolean getMsg(@RequestParam(value = "key", defaultValue = "name") String key){
        Boolean str1 =  redisTemplate.hasKey(key);
        log.info("/redistest str：{}",str1);
        System.out.println(str1);
        return str1;
    }

}
